//
//  ZH_StatesOrderViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/27.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_StatesOrderViewController.h"
#import "ZH_MineAddressViewController.h"
#import "ZH_MineOrderTopTableViewCell.h"
#import "ZH_MineOrderGoodsInfoTableViewCell.h"
#import "ZH_OrderStateOneTableViewCell.h"
@interface ZH_StatesOrderViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,weak)UITableView *tableView;
@property (nonatomic,weak)UIView *bgView;
@property (nonatomic,weak)UIImageView *addressImage;
@property (nonatomic,weak)UILabel *addressLabel;
@property (nonatomic,weak)UILabel *addressContentLabel;
@property (nonatomic,weak)UIImageView *rightImage;
@property (nonatomic,weak)UIButton *button;
@property (nonatomic,weak)UIView *bottomView;
@property (nonatomic,weak)UILabel *numLabel;
@property (nonatomic,weak)UILabel *moneyLabel;
@property (nonatomic,weak)UIButton *rightButton;
@end

@implementation ZH_StatesOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
}

- (void)initUserInterface{
    self.navigationItem.title = @"待发货";
    self.view.backgroundColor = kCommonBackgroudColor;
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(FITSCALE(70));
    }];
    [self.addressImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bgView);
        make.left.equalTo(self.view).offset(FITSCALE(11));
    }];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(FITSCALE(15));
        make.left.equalTo(self.view).offset(FITSCALE(52));
    }];
    [self.addressContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.addressLabel.mas_bottom).offset(FITSCALE(12));
        make.left.equalTo(self.addressLabel);
        make.right.equalTo(self.view).offset(FITSCALE(-41));
    }];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bgView);
        make.right.equalTo(self.view).offset(FITSCALE(-12));
    }];
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.bgView);
    }];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.height.mas_equalTo(FITSCALE(50));
    }];
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bottomView).offset(FITSCALE(11));
        make.left.equalTo(self.view).offset(FITSCALE(12));
    }];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(FITSCALE(-10));
        make.left.equalTo(self.numLabel);
    }];
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.top.equalTo(self.bottomView);
        make.width.mas_equalTo(FITSCALE(141));
    }];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView.mas_bottom).offset(FITSCALE(9));
        make.left.equalTo(self.view).offset(FITSCALE(11));
        make.right.equalTo(self.view).offset(FITSCALE(-11));
        make.bottom.equalTo(self.bottomView.mas_top);
    }];
}
#pragma mark - UITableViewDataSource,UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        ZH_MineOrderTopTableViewCell *cell = [ZH_MineOrderTopTableViewCell cellWithTableView:tableView];
        return cell;
    }
    else if (indexPath.row == 1){
        ZH_MineOrderGoodsInfoTableViewCell *cell = [ZH_MineOrderGoodsInfoTableViewCell cellWithTableView:tableView];
        return cell;
    }
    else if (indexPath.row == 2){
        ZH_OrderStateOneTableViewCell *cell = [ZH_OrderStateOneTableViewCell cellWithTableView:tableView];
        return cell;
    }
    return nil;
}

#pragma mark - button
- (void)button:(UIButton *)btn{
    ZH_MineAddressViewController *vc = [[ZH_MineAddressViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - getter,setter
- (UIView *)bgView{
    if (!_bgView) {
        UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
        [self.view addSubview:_bgView = view];
    }
    return _bgView;
}
- (UIImageView *)addressImage{
    if (!_addressImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_sjrmgs"];
        [self.view addSubview:_addressImage = image];
    }
    return _addressImage;
}
- (UILabel *)addressLabel{
    if (!_addressLabel) {
        UILabel *label = [UILabel createLabelWithText:@"收货人:胡帅帅 18784378954" font:kFontSize_30];
        label.textColor = [UIColor colorWithHexString:@"#333333"];
        [self.view addSubview:_addressLabel = label];
    }
    return _addressLabel;
}
- (UILabel *)addressContentLabel{
    if (!_addressContentLabel) {
        UILabel *label = [UILabel createLabelWithText:@"四川省成都市武侯区石羊场街道2号4栋1单元" font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#666666"];
        [self.view addSubview:_addressContentLabel = label];
    }
    return _addressContentLabel;
}
- (UIImageView *)rightImage{
    if (!_rightImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_mygetmore1"];
        [self.view addSubview:_rightImage = image];
    }
    return _rightImage;
}
- (UIButton *)button{
    if (!_button) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"" target:self action:@selector(button:)];
        button.backgroundColor = [UIColor clearColor];
        [self.view addSubview:_button = button];
    }
    return _button;
}
- (UIView *)bottomView{
    if (!_bottomView) {
        UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
        [self.view addSubview:_bottomView = view];
    }
    return _bottomView;
}
- (UILabel *)numLabel{
    if (!_numLabel) {
        UILabel *label = [UILabel createLabelWithText:@"共计1件商品" font:kFontSize_24];
        [self.view addSubview:_numLabel = label];
    }
    return _numLabel;
}
- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        UILabel *label = [UILabel createLabelWithText:@"合计:100元(含运费)" font:kFontSize_26];
        [self.view addSubview:_moneyLabel = label];
    }
    return _moneyLabel;
}
- (UIButton *)rightButton{
    if (!_rightButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"提醒商家发货" target:self action:nil];
        button.titleLabel.font = kFontSize_34;
        [button setTitleColor:kFontColorWhite forState:UIControlStateNormal];
        button.backgroundColor = [UIColor colorWithHexString:@"#00C9AE"];
        [self.view addSubview:_rightButton = button];
    }
    return _rightButton;
}
- (UITableView *)tableView{
    if (!_tableView) {
        UITableView *tableView = [UITableView createTableViewWithDelegateTarget:self];
        tableView.backgroundColor = kCommonBackgroudColor;
        tableView.separatorStyle =UITableViewCellSeparatorStyleNone;
        [tableView setCellAutoAdaptationForEstimatedRowHeight:FITSCALE(100)];
        [self.view addSubview:_tableView = tableView];
    }
    return _tableView;
}
@end
